get item from icollection

65

get item from icollection -

var foo = myICollection.OfType<YourType>().FirstOrDefault();
// or use a query
var bar = (from x in myICollection.OfType<YourType>() where x.SomeProperty == someValue select x)
	.FirstOrDefault();

Comments

Submit
0 Comments